package com.retail.lottery.colalottery.enums;


import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum DealStatusEnum {

    SUCC(0, "成功"),
    FAIL(1, "失败"),

  ;

    private final int code;
    private final String desc;

    private static final Map<Integer, DealStatusEnum> codeMap = new HashMap<>();
    private static final Map<String, DealStatusEnum> descMap = new HashMap<>();

    static {
        Arrays.stream(DealStatusEnum.values())
                .forEach(val -> {
                    codeMap.put(val.getCode(), val);
                    descMap.put(val.getDesc(), val);
                });
    }

    public static DealStatusEnum getEnumByCode(Integer code) {
        return codeMap.get(code);
    }

    public static DealStatusEnum getEnumByDesc(String desc) {
        return descMap.get(desc);
    }
}
